{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-07-22T02:19:25.228692Z",
     "start_time": "2025-07-22T02:19:24.402721Z"
    }
   },
   "source": "import pandas as pd",
   "outputs": [],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-22T02:19:39.025610Z",
     "start_time": "2025-07-22T02:19:31.454732Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 读取数据\n",
    "data = pd.read_csv('data/train.csv')"
   ],
   "id": "383205c207008dab",
   "outputs": [],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-19T07:49:35.575306Z",
     "start_time": "2025-07-19T07:49:35.565511Z"
    }
   },
   "cell_type": "code",
   "source": "data.head()",
   "id": "5772995e83c20e14",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   row_id       x       y  accuracy    time    place_id\n",
       "0       0  0.7941  9.0809        54  470702  8523065625\n",
       "1       1  5.9567  4.7968        13  186555  1757726713\n",
       "2       2  8.3078  7.0407        74  322648  1137537235\n",
       "3       3  7.3665  2.5165        65  704587  6567393236\n",
       "4       4  4.0961  1.1307        31  472130  7440663949"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>row_id</th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "      <th>place_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0.7941</td>\n",
       "      <td>9.0809</td>\n",
       "      <td>54</td>\n",
       "      <td>470702</td>\n",
       "      <td>8523065625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>5.9567</td>\n",
       "      <td>4.7968</td>\n",
       "      <td>13</td>\n",
       "      <td>186555</td>\n",
       "      <td>1757726713</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>8.3078</td>\n",
       "      <td>7.0407</td>\n",
       "      <td>74</td>\n",
       "      <td>322648</td>\n",
       "      <td>1137537235</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>7.3665</td>\n",
       "      <td>2.5165</td>\n",
       "      <td>65</td>\n",
       "      <td>704587</td>\n",
       "      <td>6567393236</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>4.0961</td>\n",
       "      <td>1.1307</td>\n",
       "      <td>31</td>\n",
       "      <td>472130</td>\n",
       "      <td>7440663949</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-22T02:24:14.728896Z",
     "start_time": "2025-07-22T02:24:14.719369Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 2. 基本的数据处理\n",
    "# 2.1 缩小数据范围\n",
    "data=data.query('x<2.5& x>2&y<1.5&y>1.0')"
   ],
   "id": "2340fd37cc6700dc",
   "outputs": [],
   "execution_count": 13
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-19T07:52:04.100746Z",
     "start_time": "2025-07-19T07:52:04.093403Z"
    }
   },
   "cell_type": "code",
   "source": "data.head()",
   "id": "5df31c939109a651",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "      row_id       x       y  accuracy    time    place_id\n",
       "112      112  2.2360  1.3655        66  623174  7663031065\n",
       "180      180  2.2003  1.2541        65  610195  2358558474\n",
       "367      367  2.4108  1.3213        74  579667  6644108708\n",
       "874      874  2.0822  1.1973       320  143566  3229876087\n",
       "1022    1022  2.0160  1.1659        65  207993  3244363975"
      ],
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>row_id</th>\n",
       "      <th>x</th>\n",
       "      <th>y</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>time</th>\n",
       "      <th>place_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>112</th>\n",
       "      <td>112</td>\n",
       "      <td>2.2360</td>\n",
       "      <td>1.3655</td>\n",
       "      <td>66</td>\n",
       "      <td>623174</td>\n",
       "      <td>7663031065</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>180</th>\n",
       "      <td>180</td>\n",
       "      <td>2.2003</td>\n",
       "      <td>1.2541</td>\n",
       "      <td>65</td>\n",
       "      <td>610195</td>\n",
       "      <td>2358558474</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>367</th>\n",
       "      <td>367</td>\n",
       "      <td>2.4108</td>\n",
       "      <td>1.3213</td>\n",
       "      <td>74</td>\n",
       "      <td>579667</td>\n",
       "      <td>6644108708</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>874</th>\n",
       "      <td>874</td>\n",
       "      <td>2.0822</td>\n",
       "      <td>1.1973</td>\n",
       "      <td>320</td>\n",
       "      <td>143566</td>\n",
       "      <td>3229876087</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1022</th>\n",
       "      <td>1022</td>\n",
       "      <td>2.0160</td>\n",
       "      <td>1.1659</td>\n",
       "      <td>65</td>\n",
       "      <td>207993</td>\n",
       "      <td>3244363975</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 7
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-22T02:19:59.629748Z",
     "start_time": "2025-07-22T02:19:58.652962Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 2.2 处理时间特征\n",
    "time_value = pd.to_datetime(data['time'], unit='s')"
   ],
   "id": "7e07886a6a7dd825",
   "outputs": [],
   "execution_count": 6
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-22T02:20:07.627257Z",
     "start_time": "2025-07-22T02:20:07.623231Z"
    }
   },
   "cell_type": "code",
   "source": "date=pd.DatetimeIndex(time_value)",
   "id": "458473279725b4ee",
   "outputs": [],
   "execution_count": 8
  },
  {
   "metadata": {},
   "cell_type": "code",
   "source": "data['day']=date.day",
   "id": "dddc295930dcfd06",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "14eab2c5993722"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
